//从桌面拖动图片到web

QZONE.Finder.file.dragIn('.popup_qzonefinder', function(name, imgBase64){
	QZONE.Finder.Loader.show();
	ItemFactory.addItem({
		type: 1,
		title: name,
		img: imgBase64
	});
});

//快捷键绑定
QZONE.QuitKey = {
	isInit : false,
	keysMap : [],
	init : function(){
		var p = QZONE.QuitKey;
		document.addEventListener('keydown', QZONE.QuitKey.delegate);
	},
	getKeyCode: function(str){
		str = str.toUpperCase();
		var keyCode = 0;
		if(str.length==1){
			keyCode = str.charCodeAt(0);
		} else {
			switch(str){
				case 'TAB': 
					keyCode = 9;
					break;
				case 'ENTER': 
					keyCode = 13;
					break;
				case 'ESC': 
					keyCode = 27;
					break;
				case 'LEFT': 
					keyCode = 37;
					break;
				case 'UP': 
					keyCode = 38;
					break;
				case 'RIGHT': 
					keyCode = 39;
					break;
				case 'DOWN': 
					keyCode = 40;
					break;
			}
		}
		return keyCode;
	},
	bindKey : function(callback, keyChar, isCtrl){
		var p = QZONE.QuitKey;
		if(!p.isInit){
			p.init();
		}
		var keyCode = p.getKeyCode(keyChar);
		p.keysMap[keyCode] = {
			callback: callback,
			isCtrl: isCtrl
		};
	},
	delegate : function(evt){
		var p = QZONE.QuitKey;
		var keyCode = evt.keyCode;
		var obj = p.keysMap[keyCode];
		if(obj){
			if(!!obj.isCtrl != evt.ctrlKey){
				return;
			}
			obj.callback();
			evt.preventDefault();
		}
	}
}

//定义快捷键
QZONE.QuitKey.bindKey(ItemFactory.Pager.prePage, 'LEFT', true);
QZONE.QuitKey.bindKey(ItemFactory.Pager.nextPage, 'RIGHT', true);
QZONE.QuitKey.bindKey(QZONE.Finder.Loader.swap, 'O', true);

